﻿using System;
using System.Collections.Generic;
  
using SiteUnity.Layers.Entity.General;
using SiteUnity.Layers.Core.Provider.PageItems;
using SiteUnity.Layers.Entity.PageItems.Contents;
using SiteUnity.Frame.Common.Tools.Data;

namespace SiteUnity.Layers.Application.Contents
{
    public class ContentManager
    {
        static private ContentProvider _contentprovider = new ContentProvider();

        public ContentManager() { }

        static public Content insertContent(Page page, Content content)
        {
            return _contentprovider.insertContent(page, content);
        }

        static public Content insertContent(Content content)
        {
            return insertContent(SiteManager.Website.CurrentPage, content);
        }

        static public List<Content> getContentByPage(Page page)
        {
            return _contentprovider.selectContentByPage(page);
        }

        static public List<Content> getContentByPage()
        {
            return getContentByPage(SiteManager.Website.CurrentPage);
        }

        static public List<ContentType> ContentTypes
        {
            get
            {
                List<ContentType> contentTypes;

                Cache.AddIfNotExists("ContentType", out contentTypes, _contentprovider, "selectContentType", null);

                return contentTypes;
            }
        }

        
    }
}
